package com.cxh.rmsq.ui.adapter.self

import android.graphics.Color
import android.graphics.Typeface
import android.util.TypedValue
import android.view.View
import android.widget.TextView
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.module.LoadMoreModule
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.cxh.rmsq.R
import com.cxh.rmsq.db.model.GroupEntity


/**
 *
 */
class SelectHoriTypeListAdapter() :
    BaseQuickAdapter<GroupEntity, BaseViewHolder>(R.layout.item_select_hori_type),
    LoadMoreModule {
    private var selectPos = 0

    fun getSelectPos(): Int {
        return selectPos
    }

    fun setSelectPos(selectPos: Int) {
        this.selectPos = selectPos
    }

    override fun convert(holder: BaseViewHolder, item: GroupEntity) {
        with(holder) {

            setText(R.id.tv_category_title, item.name)

            if (selectPos == holder.layoutPosition) {
                holder.setTextColor(R.id.tv_category_title,Color.parseColor("#FE9D01"))
                (holder.getView<View>(R.id.tv_category_title) as TextView).setTypeface(Typeface.DEFAULT_BOLD)
                (holder.getView<View>(R.id.tv_category_title) as TextView).setTextSize(
                    TypedValue.COMPLEX_UNIT_SP,
                    15f
                )
            } else {
                holder.setTextColor(R.id.tv_category_title,Color.parseColor("#666666"))
                (holder.getView<View>(R.id.tv_category_title) as TextView).setTypeface(Typeface.DEFAULT)
                (holder.getView<View>(R.id.tv_category_title) as TextView).setTextSize(
                    TypedValue.COMPLEX_UNIT_SP,
                    14f
                )
            }
        }
    }
}